<template>
<div class="base-form">
	<template v-if="step === 1">
		<h3>房屋基础信息</h3>
		<van-field
			v-model="formData.jzrks"
			label="1.总居住人数(人)"
			placeholder="请输入"
			required
			type="digit"
			:rules="validator.number1to100"
		>
			<template #label>
				<p>1.总居住人数(人)</p>
				<span v-if="initData.jzrks_diff">{{ initData.jzrks_diff }}</span>
			</template>
		</van-field>
		<van-field
			v-model="formData.zzrs"
			label="2.租住人数(人)"
			placeholder="请输入"
			required
			type="digit"
			:rules="validator.number2"
		>
			<template #label>
				<p>2.租住人数(人)</p>
				<span v-if="initData.zzrs_diff">{{ initData.zzrs_diff }}</span>
			</template>
		</van-field>
		<van-field
			v-model="formData.cs"
			label="3.房屋层数(层)"
			placeholder="请输入"
			required
			@input="onStoreyInput"
			type="digit"
			:rules="validator.number1to7"
		>
			<template #label>
				<p>3.房屋层数(层)</p>
				<span v-if="initData.cs_diff">{{ initData.cs_diff }}</span>
			</template>
		</van-field>
		<van-field
			v-model="formData.fjsl"
			label="4.房间数量(个)"
			type="digit"
			placeholder="请输入"
			required
			:rules="validator.number1to100"
		>
			<template #label>
				<p>4.房间数量(个)</p>
				<span v-if="initData.fjsl_diff">{{ initData.fjsl_diff }}</span>
			</template>
		</van-field>
		<van-field
			v-model="formData.jzfjs"
			label="5.出租房间数量(个)"
			placeholder="请输入"
			required
			type="digit"
			:rules="validator.number5"
		>
			<template #label>
				<p>5.出租房间数量(个)</p>
				<span v-if="initData.jzfjs_diff">{{ initData.jzfjs_diff }}</span>
			</template>
		</van-field>
		<van-field
			v-model="formData.bdfwjzrydddzxcsl"
			label="6.本房屋居住人员的电动自行车数量"
			placeholder="请输入"
			required
			type="digit"
			:rules="validator.number"
		>
			<template #label>
				<p>6.本房屋居住人员的电动自行车数量</p>
				<span v-if="initData.bdfwjzrydddzxcsl_diff">{{ initData.bdfwjzrydddzxcsl_diff }}</span>
			</template>
		</van-field>
		<van-field
			class="field-column"
			label="7.充电方式"
			required
			placeholder="请选择"
			:rules="validator.business"
		>
			<template #label>
				<p>7.充电方式</p>
				<span v-if="initData.cdfs_diff">{{ initData.cdfs_diff }}</span>
			</template>
			<template #input>
				<van-checkbox-group v-model="formData.cdfs" direction="horizontal">
					<van-checkbox
						v-for="item in echoData.recharge"
						:name="item"
						:key="item"
						shape="square"
					>
						{{ item }}
					</van-checkbox>
				</van-checkbox-group>
			</template>
		</van-field>
		<van-field
			v-if="formData.cdfs?.includes('其他')"
			v-model="formData.cdfsqtbz"
			label="其他充电方式"
			class="field-textarea field-column"
			placeholder="请输入"
			required
			type="textarea"
			:rules="validator.desc"
		>
			<template #label>
				<p>其他充电方式</p>
				<span v-if="initData.cdfsqtbz_diff">{{ initData.cdfsqtbz_diff }}</span>
			</template>
		</van-field>
		<van-field
			v-model="formData.czryrs"
			label="8.出租人员从事外卖、闪送、代驾等职业的人数"
			placeholder="请输入"
			required
			type="digit"
			:rules="validator.number1to100"
		>
			<template #label>
				<p>8.出租人员从事外卖、闪送、代驾等职业的人数</p>
				<span v-if="initData.czryrs_diff">{{ initData.czryrs_diff }}</span>
			</template>
		</van-field>
		<van-field
			v-model="formData.cjzwqtjyyt"
			label="9.除居住外是否存在其他经营业态"
			placeholder="请选择"
			required
			:rules="validator.boolean"
		>
			<template #label>
				<p>9.除居住外是否存在其他经营业态</p>
				<span v-if="initData.cjzwqtjyyt_diff">{{ initData.cjzwqtjyyt_diff }}</span>
			</template>
			<template #input>
				<van-radio-group v-model="formData.cjzwqtjyyt" direction="horizontal">
					<van-radio
						v-for="item in echoData.boolean"
						:name="item.value"
						:key="item.value"
					>
						{{ item.label }}
					</van-radio>
				</van-radio-group>
			</template>
		</van-field>
		<van-field
			v-if="+formData.cjzwqtjyyt === 1"
			class="field-column"
			placeholder="请选择"
			:rules="validator.business"
		>
			<template #label>
				<span v-if="initData.cjzwqtjyyt_diff">{{ initData.cjzwqtjyyt_diff }}</span>
			</template>
			<template #input>
				<van-checkbox-group v-model="formData.cjzwqtjyytmsg" direction="horizontal">
					<van-checkbox
						v-for="item in echoData.business"
						:name="item"
						:key="item"
						shape="square"
					>
						{{ item }}
					</van-checkbox>
				</van-checkbox-group>
			</template>
		</van-field>
	</template>

	<template v-if="step === 2">
		<h3>安全疏散</h3>
		<van-field
			v-model="formData.jzscxyaqcksl"
			label="1.房屋首层现有安全出口的数量(个)"
			placeholder="请输入"
			@input="onExitInput"
			required
      type="digit"
			:rules="validator.number1to10"
		>
			<template #label>
				<p>1.房屋首层现有安全出口的数量(个)</p>
				<span v-if="initData.jzscxyaqcksl_diff">{{ initData.jzscxyaqcksl_diff }}</span>
			</template>
		</van-field>
		<van-field
			v-model="formData.jzxyssltsl"
			label="2.房屋现有疏散楼梯的数量(个)"
			@input="onInput"
			placeholder="请输入"
			required
      type="digit"
			:rules="validator.number1to10"
		>
			<template #label>
				<p>2.房屋现有疏散楼梯的数量(个)</p>
				<span v-if="initData.jzxyssltsl_diff">{{ initData.jzxyssltsl_diff }}</span>
			</template>
		</van-field>
		<van-field
			v-model="formData.jzscmj"
			label="3.房屋建筑面积(平方米)"
			placeholder="请输入"
			required
			type="number"
			:rules="validator.number"
		>
			<template #label>
				<p>3.房屋建筑面积(平方米)</p>
				<span v-if="initData.jzscmj_diff">{{ initData.jzscmj_diff }}</span>
			</template>
		</van-field>
		<van-field
			v-model="formData.ckfhwggptzlsl"
			label="4.窗口防护网、广告牌、铁栅栏数量(个)"
			placeholder="请输入"
			required
			type="digit"
			:rules="validator.number1to100"
		>
			<template #label>
				<p>4.窗口防护网、广告牌、铁栅栏数量(个)</p>
				<span v-if="initData.ckfhwggptzlsl_diff">{{ initData.ckfhwggptzlsl_diff }}</span>
			</template>
		</van-field>
<!--		<template v-if="!(-->
<!--			(echoData.storeyCount >= 2 && echoData.stairsCount >= 2 && echoData.exitCount >= 2)-->
<!--			|| (echoData.storeyCount <= 1 && echoData.exitCount >= 2 && echoData.stairsCount >= 0)-->
<!--			)">-->
			<van-field
				class="field-column field-no-border"
				label="5.建设人员疏散通道"
				placeholder="请选择"
				required
				:rules="validator.boolean"
			>
				<template #label>
					<p>5.建设人员疏散通道</p>
					<span v-if="initData.jsrysstd_diff">{{ initData.jsrysstd_diff }}</span>
				</template>
				<template #input>
					<van-radio-group v-model="formData.jsrysstd" direction="horizontal" @click="onBuildClick">
						<van-radio
							v-for="item in echoData.exit"
							:name="item.value"
							:key="item.value"
						>
							{{ item.label }}
						</van-radio>
					</van-radio-group>
				</template>
			</van-field>
			<van-field
				v-if="formData.jsrysstd === '已完成'"
				class="field-column"
				placeholder="请选择"
				required
				:rules="validator.boolean"
			>
				<template #input>
					<van-checkbox-group v-model="formData.sstdjsqk">
						<van-checkbox
							v-for="item in echoData.status1"
							:name="item"
							:key="item"
							shape="square"
						>
							{{ item }}
						</van-checkbox>
					</van-checkbox-group>
				</template>
			</van-field>
			<van-field
				v-if="formData.jsrysstd === '未完成'"
				class="field-column"
				placeholder="请选择"
				required
				:rules="validator.boolean"
			>
				<template #input>
					<van-radio-group v-model="formData.sstdjsqk">
						<van-radio
							v-for="item in echoData.status2"
							:name="item"
							:key="item"
						>
							{{ item }}
						</van-radio>
					</van-radio-group>
				</template>
			</van-field>
<!--		</template>-->
		<template v-if="echoData.storeyCount >= 2">
			<van-field
				v-model="formData.sfazfztsss"
				label="6.是否安装软梯逃生绳等辅助逃生设施"
				placeholder="请选择"
				required
				:rules="validator.boolean"
			>
				<template #label>
					<p>6.是否安装软梯逃生绳等辅助逃生设施</p>
					<span v-if="initData.sfazfztsss_diff">{{ initData.sfazfztsss_diff }}</span>
				</template>
				<template #input>
					<van-radio-group v-model="formData.sfazfztsss" direction="horizontal">
						<van-radio
							v-for="item in echoData.boolean"
							:name="item.value"
							:key="item.value"
						>
							{{ item.label }}
						</van-radio>
					</van-radio-group>
				</template>
			</van-field>
			<van-field
				v-model="formData.ywgdlttxwd"
				label="7.楼内有无固定楼梯通向屋顶或室外平台"
				placeholder="请选择"
				required
				:rules="validator.boolean"
			>
				<template #label>
					<p>7.楼内有无固定楼梯通向屋顶或室外平台</p>
					<span v-if="initData.ywgdlttxwd_diff">{{ initData.ywgdlttxwd_diff }}</span>
				</template>
				<template #input>
					<van-radio-group v-model="formData.ywgdlttxwd" direction="horizontal">
						<van-radio
							v-for="item in echoData.haveOrNot"
							:name="item.value"
							:key="item.value"
						>
							{{ item.label }}
						</van-radio>
					</van-radio-group>
				</template>
			</van-field>
		</template>
    <van-field
      :label="
        echoData.storeyCount >= 2
          ? '8.疏散通道是否合格'
          : '6.疏散通道是否合格'
      "
      placeholder="请选择"
      required
      :rules="validator.boolean"
    >
      <template #input>
        <van-radio-group
            v-model="formData.tdsfdb"
            direction="horizontal"
            :disabled="+formData.cs === 1"
        >
          <van-radio
              v-for="item in echoData.exit1"
              :name="item.value"
              :key="item.value"
              :disabled="item.disabled"
          >
            {{ item.label }}
          </van-radio>
        </van-radio-group>
      </template>
    </van-field>
    <!-- 疏散通道是否合格 选择是 加照片 -->
	<van-field
		v-if="['是', '否'].includes(formData.tdsfdb)"
		class="field-column"
		:rules="validator.image"
	>
		<template #input>
		<component :is="upload" :limit="5" v-model="formData.sfmzstdPhoto" />
		</template>
	</van-field>
	<!-- 疏散通道是否合格 选择是 加描述 -->
	<van-field
		v-if="formData.tdsfdb === '否'"
		v-model="formData.sfmzstdMsg"
		label="隐患描述"
		class="field-textarea field-column"
		placeholder="请输入"
		type="textarea"
	/>
    <van-field
		v-if="formData.tdsfdb === '否'"
		class="field-column"
		v-model="formData.sfmzstdZgqk"
		label="隐患整改情况"
		placeholder="请选择"
		required
		:rules="validator.boolean"
	>
		<template #input>
			<van-radio-group v-model="formData.sfmzstdZgqk" direction="horizontal">
				<van-radio
					v-for="item in echoData.boolean3"
					:name="item.value"
					:key="item.value"
				>
					{{ item.label }}
				</van-radio>
			</van-radio-group>
		</template>
	</van-field>
    <van-field
		v-if="formData.sfmzstdZgqk === '1'"
		class="field-column"
		:rules="validator.image"
	>
		<template #input>
			<component
				:is="upload"
				v-model="formData.sfmzstdZgphoto"
			/>
		</template>
	</van-field>
	</template>

	<template v-if="step === 3">
		<h3>设施器材</h3>
		<van-field
			v-model="formData.mhqsl"
			label="1.灭火器数量(个)"
			placeholder="请输入"
			required
			type="digit"
			:rules="validator.number"
		>
			<template #label>
				<p>1.灭火器数量(个)</p>
				<span v-if="initData.mhqsl_diff">{{ initData.mhqsl_diff }}</span>
			</template>
		</van-field>
		<van-field
			v-model="formData.fytsmz"
			label="2.防烟逃生面罩数量(套)"
			placeholder="请输入"
			required
			type="digit"
			:rules="validator.number"
		>
			<template #label>
				<p>2.防烟逃生面罩数量(套)</p>
				<span v-if="initData.fytsmz_diff">{{ initData.fytsmz_diff }}</span>
			</template>
		</van-field>
		<van-field
			v-model="formData.xggdjsbp"
			label="3.悬挂固定警示标牌数量(张)"
			placeholder="请输入"
			required
			type="digit"
			:rules="validator.number"
		>
			<template #label>
				<p>3.悬挂固定警示标牌数量(张)</p>
				<span v-if="initData.xggdjsbp_diff">{{ initData.xggdjsbp_diff }}</span>
			</template>
		</van-field>
		<van-field
			v-model="formData.jzsyjyplmhxts"
			label="4.房屋简易消防喷头数量(个)"
			placeholder="请输入"
			required
			type="digit"
			:rules="validator.number"
		>
			<template #label>
				<p>4.房屋简易消防喷头数量(个)</p>
				<span v-if="initData.jzsyjyplmhxts_diff">{{ initData.jzsyjyplmhxts_diff }}</span>
			</template>
		</van-field>
		<van-field
			v-model="formData.jzszlwxdlgybjqs"
			label="5.房屋烟感报警器数量(个)"
			placeholder="请输入"
			required
			type="digit"
			:rules="validator.number"
		>
			<template #label>
				<p>5.房屋烟感报警器数量(个)</p>
				<span v-if="initData.jzszlwxdlgybjqs_diff">{{ initData.jzszlwxdlgybjqs_diff }}</span>
			</template>
		</van-field>
	</template>

	<template v-if="step === 4">
		<h3>其他</h3>
		<van-field
			v-model="formData.wdwhjgfjgqsyyrkrgbdj"
			label="1.屋顶、围护结构、房间隔墙使用易燃可燃夹芯彩钢板搭建且出租住人"
			placeholder="请选择"
			required
			:rules="validator.boolean"
		>
			<template #label>
				<p>1.屋顶、围护结构、房间隔墙使用易燃可燃夹芯彩钢板搭建且出租住人</p>
				<span v-if="initData.wdwhjgfjgqsyyrkrgbdj_diff">{{ initData.wdwhjgfjgqsyyrkrgbdj_diff }}</span>
			</template>
			<template #input>
				<van-radio-group v-model="formData.wdwhjgfjgqsyyrkrgbdj" direction="horizontal">
					<van-radio
						v-for="item in echoData.boolean"
						:name="item.value"
						:key="item.value"
					>
						{{ item.label }}
					</van-radio>
				</van-radio-group>
			</template>
		</van-field>
        <!-- 屋顶、围护结构、房间隔墙使用易燃可燃夹芯彩钢板搭建且出租住人 选择是 加照片 -->
        <!-- v-if="formData.wdwhjgfjgqsyyrkrgbdj === '1'" -->
		<van-field
            v-if="['0', '1'].includes(formData.wdwhjgfjgqsyyrkrgbdj)"
			class="field-column"
			:rules="validator.image"
		>
			<template #input>
			<component :is="upload" :limit="5" v-model="formData.sfczjxgbczzrPhoto" />
			</template>
		</van-field>
		<!-- 屋顶、围护结构、房间隔墙使用易燃可燃夹芯彩钢板搭建且出租住人 选择是 加描述 -->
		<van-field
			v-if="formData.wdwhjgfjgqsyyrkrgbdj === '1'"
			v-model="formData.sfczjxgbczzrMsg"
			label="隐患描述"
			class="field-textarea field-column"
			placeholder="请输入"
			type="textarea"
		/>
		<!-- 屋顶、围护结构、房间隔墙使用易燃可燃夹芯彩钢板搭建且出租住人 选择是 整改情况 -->
        <van-field
		    v-if="formData.wdwhjgfjgqsyyrkrgbdj === '1'"
			class="field-column"
			v-model="formData.sfczjxgbczzrZgqk"
			label="隐患整改情况"
			placeholder="请选择"
			required
			:rules="validator.boolean"
		>
			<template #input>
				<van-radio-group v-model="formData.sfczjxgbczzrZgqk" direction="horizontal">
					<van-radio
						v-for="item in echoData.boolean3"
						:name="item.value"
						:key="item.value"
					>
						{{ item.label }}
					</van-radio>
				</van-radio-group>
			</template>
		</van-field>
		<!-- 屋顶、围护结构、房间隔墙使用易燃可燃夹芯彩钢板搭建且出租住人 选择是 整改情况  加整改照片 -->
		<van-field
			v-if="formData.sfczjxgbczzrZgqk === '1'"
			class="field-column"
			:rules="validator.image"
		>
			<template #input>
				<component
					:is="upload"
					v-model="formData.sfczjxgbczzrZgphoto"
				/>
			</template>
		</van-field>
		<van-field
			v-model="formData.sstdsyyrkrclzx"
			label="2.疏散通道使用易燃可燃材料装修"
			placeholder="请选择"
			required
			:rules="validator.boolean"
		>
			<template #label>
				<p>2.疏散通道使用易燃可燃材料装修</p>
				<span v-if="initData.sstdsyyrkrclzx_diff">{{ initData.sstdsyyrkrclzx_diff }}</span>
			</template>
			<template #input>
				<van-radio-group v-model="formData.sstdsyyrkrclzx" direction="horizontal">
					<van-radio
						v-for="item in echoData.boolean"
						:name="item.value"
						:key="item.value"
					>
						{{ item.label }}
					</van-radio>
				</van-radio-group>
			</template>
		</van-field>
        <!-- 疏散通道使用易燃可燃材料装修 选择是 加照片 -->
        <!-- v-if="formData.sstdsyyrkrclzx === '1'" -->
		<van-field
            v-if="['0', '1'].includes(formData.sstdsyyrkrclzx)"
			class="field-column"
			:rules="validator.image"
		>
			<template #input>
			<component :is="upload" :limit="5" v-model="formData.sstdsyyrkrclzxPhoto" />
			</template>
		</van-field>
		<!-- 疏散通道使用易燃可燃材料装修 选择是 加描述 -->
		<van-field
			v-if="formData.sstdsyyrkrclzx === '1'"
			v-model="formData.sstdsyyrkrclzxMsg"
			label="隐患描述"
			class="field-textarea field-column"
			placeholder="请输入"
			type="textarea"
		/>
		<!-- 疏散通道使用易燃可燃材料装修 选择是 加整改情况 -->
        <van-field
            v-if="formData.sstdsyyrkrclzx === '1'"
			class="field-column"
			v-model="formData.sstdsyyrkrclzxZgqk"
			label="隐患整改情况"
			placeholder="请选择"
			required
			:rules="validator.boolean"
		>
			<template #input>
				<van-radio-group v-model="formData.sstdsyyrkrclzxZgqk" direction="horizontal">
					<van-radio
						v-for="item in echoData.boolean3"
						:name="item.value"
						:key="item.value"
					>
						{{ item.label }}
					</van-radio>
				</van-radio-group>
			</template>
		</van-field>
        <!-- 疏散通道使用易燃可燃材料装修 选择是 加整改照片 -->
        <van-field
			v-if="formData.sstdsyyrkrclzxZgqk === '1'"
			class="field-column"
			:rules="validator.image"
		>
			<template #input>
				<component
					:is="upload"
					v-model="formData.sstdsyyrkrclzxZgphoto"
				/>
			</template>
		</van-field>
		<van-field
			v-model="formData.gryssdcsszblyyqksddp"
			label="3.供人员疏散的场院、内院、天井设置不利于烟气扩散的顶棚、雨棚等"
			placeholder="请选择"
			required
			:rules="validator.boolean"
		>
			<template #label>
				<p>3.供人员疏散的场院、内院、天井设置不利于烟气扩散的顶棚、雨棚等</p>
				<span v-if="initData.gryssdcsszblyyqksddp_diff">{{ initData.gryssdcsszblyyqksddp_diff }}</span>
			</template>
			<template #input>
				<van-radio-group v-model="formData.gryssdcsszblyyqksddp" direction="horizontal">
					<van-radio
						v-for="item in echoData.boolean"
						:name="item.value"
						:key="item.value"
					>
						{{ item.label }}
					</van-radio>
				</van-radio-group>
			</template>
		</van-field>
        <!--供人员疏散的场院、内院、天井设置不利于烟气扩散的顶棚、雨棚 选择是 加照片 -->
        <!-- v-if="formData.gryssdcsszblyyqksddp === '1'" -->
		<van-field
            v-if="['0', '1'].includes(formData.sstdsyyrkrclzx)"
			class="field-column"
			:rules="validator.image"
		>
			<template #input>
			<component :is="upload" :limit="5" v-model="formData.gryssdcsszblyyqksddpPhoto" />
			</template>
		</van-field>
		<!-- 供人员疏散的场院、内院、天井设置不利于烟气扩散的顶棚、雨棚 选择是 加描述 -->
		<van-field
			v-if="formData.gryssdcsszblyyqksddp === '1'"
			v-model="formData.gryssdcsszblyyqksddpMsg"
			label="隐患描述"
			class="field-textarea field-column"
			placeholder="请输入"
			type="textarea"
		/>
		<!-- 供人员疏散的场院、内院、天井设置不利于烟气扩散的顶棚、雨棚 选择是 加整改情况 -->
	    <van-field
			v-if="formData.gryssdcsszblyyqksddp === '1'"
			class="field-column"
			v-model="formData.gryssdcsszblyyqksddpZgqk"
			label="隐患整改情况"
			placeholder="请选择"
			required
			:rules="validator.boolean"
		>
			<template #input>
				<van-radio-group v-model="formData.gryssdcsszblyyqksddpZgqk" direction="horizontal">
					<van-radio
						v-for="item in echoData.boolean3"
						:name="item.value"
						:key="item.value"
					>
						{{ item.label }}
					</van-radio>
				</van-radio-group>
			</template>
		</van-field>
	    <van-field
			v-if="formData.gryssdcsszblyyqksddpZgqk === '1'"
			class="field-column"
			:rules="validator.image"
		>
			<template #input>
				<component
					:is="upload"
					v-model="formData.gryssdcsszblyyqksddpZgphoto"
				/>
			</template>
		</van-field>
	</template>
</div>
</template>

<script setup>
import { reactive, defineProps, watch } from 'vue'
import upload from '@/components/upload'
const props = defineProps({
	formData: {
		type: Object,
		default: () => {}
	},
	initData: {
		type: Object,
		default: () => {}
	},
	step: {
		type: Number,
		default: 1
	}
})

const validateMax100 = (val) =>
    new Promise((resolve) => {
      if (val <= 500) {
        resolve(true)
      } else {
        resolve(false)
      }
    })
const validateMax10 = (val) =>
    new Promise((resolve) => {
      if (val <= 10) {
        resolve(true)
      } else {
        resolve(false)
      }
    })
const validateMax7 = (val) =>
    new Promise((resolve) => {
      if (val <= 7) {
        resolve(true)
      } else {
        resolve(false)
      }
    })

const validateDep1 = (val) =>
    new Promise((resolve) => {
      if (+val <= +props.formData.jzrks) {
        resolve(true)
      } else {
        resolve(false)
      }
    })
const validateDep4 = (val) =>
    new Promise((resolve) => {
      if (+val <= +props.formData.fjsl) {
        resolve(true)
      } else {
        resolve(false)
      }
    })
const validateNumber = (val) =>
	new Promise((resolve) => {
		if (val && val >= 0) {
			resolve(true)
		} else {
			resolve(false)
		}
	})
const validateNumber1 = (val) =>
	new Promise((resolve) => {
		if (val && val >= 1) {
			resolve(true)
		} else {
			resolve(false)
		}
	})

const echoData = reactive({
	stairsCount: 0,
	exitCount: 0,
	storeyCount: 0,
	business: [
		'餐饮',
		'商店',
		'美容美发',
		'KTV',
		'网吧',
		'美甲美睫',
		'棋牌室',
		'茶社',
		'足疗、按摩',
		'教学培训',
		'医疗诊所',
		'加工生产',
		'其它',
	],
	boolean: [
		{ label: '是', value: '1' },
		{ label: '否', value: '0' }
	],
	haveOrNot: [
		{ label: '有', value: '1' },
		{ label: '无', value: '0' }
	],
	boolean3: [
		{ label: '已整改', value: '1' },
		{ label: '未整改', value: '0' }
	],
  exit1: [
    { label: "是", value: "是" },
    { label: "否", value: "否" },
  ],
	exit: [
		{ label: '已完成', value: '已完成' },
		{ label: '未完成', value: '未完成' }
	],
	status1: [
		'建筑室内增设疏散楼梯',
		'建筑室外或内天井增设疏散楼梯',
		'利用相邻或相近建筑疏散',
	],
	status2: [
		'正在制定方案',
		'正在施工改造',
	],
	recharge: [
		'单插口',
		'集中充电桩',
		'单仓口',
		'充(换)电柜',
		'其他',
	]
})
const validator = {
  number1to100: [
    { validator: validateNumber, message: '请输入正数' },
    { validator: validateMax100, message: '最大值不能超过500' },
  ],
  number1to10: [
    { validator: validateNumber, message: '请输入正数' },
    { validator: validateMax10, message: '最大值不能超过10' },
  ],
  //第2项专用
  number2: [
    { validator: validateNumber, message: '请输入正数' },
    { validator: validateMax100, message: '最大值不能超过500' },
    { validator: validateDep1, message: '不能超过总居住人数' },
  ],
  //第5项专用
  number5: [
    { validator: validateNumber, message: '请输入正数' },
    { validator: validateMax100, message: '最大值不能超过500' },
    { validator: validateDep4, message: '不能超过总房间数' },
  ],
  number1to7: [
    { validator: validateNumber1, message: '最小值为1' },
    { validator: validateMax7, message: '最大值不能超过7' },
  ],
  number: [
    { required: true, message: '请输入' },
    { validator: validateNumber, message: '请输入正数' }
  ],
  desc: [
    { required: true, message: '请输入' },
  ],
	number1: [
		{ required: true, message: '请输入' },
		{ validator: validateNumber1, message: '最小值为1' }
	],
	business: [{ required: true, message: '请选择' }],
	boolean: [{ required: true, message: '请选择' }],
	// image: [{ required: true, message: '请上传图片' }],
}

const onBuildClick = () => {
	props.formData.sstdjsqk = props.formData.jsrysstd	=== '已完成' ? [] : ''
}

const onStoreyInput = e => {
	echoData.storeyCount = +e.target.value
}
const onExitInput = e => {
	echoData.exitCount = +e.target.value
}
const onInput = (e) => {
	echoData.stairsCount = +e.target.value
}

watch(() => props.initData?.id, () => {
	echoData.storeyCount = props.initData.cs
}, { immediate: true })
watch(() => props.formData, () => {
  if (+props.formData.cs === 1) {
    if (+props.formData.jzscmj < 200 && +props.formData.jzscxyaqcksl >= 1) {
      props.formData.tdsfdb = '是'
    } else if (+props.formData.jzscmj >= 200 && +props.formData.jzscxyaqcksl >= 2) {
      props.formData.tdsfdb = '是'
    } else {
      props.formData.tdsfdb = '否'
    }
  }
  // if (props.formData.cs > 2) {
  //   if (props.formData.jzxyssltsl >= 2 && props.formData.jzscxyaqcksl >= 2) {
  //     props.formData.tdsfdb = '是'
  //   } else {
  //     props.formData.tdsfdb = '否'
  //   }
  // }
}, { immediate: true, deep: true })

watch(() => props.formData.tdsfdb, (newVal) => {
  if (newVal === '否') {
    // 当选择"否"时，清除照片/隐患描述
    // props.formData.sfmzstdPhoto = []
    props.formData.sfmzstdMsg = ''
    props.formData.sfmzstdZgqk = ''
    props.formData.sfmzstdZgphoto = []
  }
})

watch(() => props.formData.wdwhjgfjgqsyyrkrgbdj, (newVal) => {
  if (newVal === '0') {
    // 当选择"否"时，清除照片/隐患描述
    // props.formData.sfczjxgbczzrPhoto = []
    props.formData.sfczjxgbczzrMsg = ''
    props.formData.sfczjxgbczzrZgqk = ''
    props.formData.sfczjxgbczzrZgphoto = []
  }
})

watch(() => props.formData.sstdsyyrkrclzx, (newVal) => {
  if (newVal === '0') {
    // 当选择"否"时，清除照片/隐患描述
    // props.formData.sstdsyyrkrclzxPhoto = []
    props.formData.sstdsyyrkrclzxMsg = ''
    props.formData.sstdsyyrkrclzxZgqk = ''
    props.formData.sstdsyyrkrclzxZgphoto = []
  }
})

watch(() => props.formData.gryssdcsszblyyqksddp, (newVal) => {
  if (newVal === '0') {
    // 当选择"否"时，清除照片/隐患描述
    // props.formData.gryssdcsszblyyqksddpPhoto = []
    props.formData.gryssdcsszblyyqksddpMsg = ''
    props.formData.gryssdcsszblyyqksddpZgqk = ''
    props.formData.gryssdcsszblyyqksddpZgphoto = []
  }
})
</script>

<style scoped lang="less">
.base-form {
	:deep(.van-cell) {
		.van-field__label {
			&:before {
				position: absolute;
				left: 24px;
			}
			p {
				color: var(--title-color);
			}
			span {
				color: #ff976a;
				font-size: 24px;
			}
		}
	}
}
</style>
